package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.service.HystrixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/payment")
public class HystrixController {
    @Value("${server.port}")
    private String serverport;

    @Autowired
    private HystrixService hystrixService;

    @GetMapping("/hystrix/paymentInfo_OK/{id}")
    public String paymentInfo_OK(@PathVariable Long id){
        return hystrixService.paymentInfo_OK(id);
    }

    @GetMapping("/hystrix/paymentInfo_Timeout/{id}")
    public String paymentInfo_Timeout(@PathVariable Long id){
        return hystrixService.paymentInfo_Timeout(id);
    }
    //*********服务熔断************
    @GetMapping("/hystrix/circuit/{id}")
    public String circuit(@PathVariable Long id){
        return hystrixService.paymentCircuitBreaker(id);
    }
}
